home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_01
/
1101118a
< prev
next >
Wrap
Text File
|
1992-11-01
|
954b
|
39 lines
/* tdate.c: Test date_interval() */
#include <stdio.h>
#include <stdlib.h>
#include "date.h"
main()
{
Date d1, d2, *result;
int nargs;
/* Read in two dates - assume 1st precedes 2nd */
fputs("Enter a date, MM/DD/YY> ",stderr);
nargs = scanf("%d/%d/%d%*c", &d1.month,
&d1.day, &d1.year);
if (nargs != 3)
return EXIT_FAILURE;
fputs("Enter a later date, MM/DD/YY> ",stderr);
nargs = scanf("%d/%d/%d%*c", &d2.month,
&d2.day, &d2.year);
if (nargs != 3)
return EXIT_FAILURE;
/* Compute interval in years, months, and days */
result = date_interval(&d1, &d2);
printf("years: %d, months: %d, days: %d\n",
result->year, result->month, result->day);
return EXIT_SUCCESS;
}
/* Sample Execution:
Enter a date, MM/DD/YY> 10/1/51
Enter a later date, MM/DD/YY> 10/6/92
years: 41, months: 0, days: 5
*/
/* End of File */